<?php if (!defined('THINK_PATH')) exit(); /*a:6:{s:81:"D:\Software\phpstudy_pro\WWW\asks\public/../application/home\view\index\info.html";i:1638780335;s:67:"D:\Software\phpstudy_pro\WWW\asks\application\home\view\layout.html";i:1638770506;s:72:"D:\Software\phpstudy_pro\WWW\asks\application\home\view\common\meta.html";i:1636163362;s:74:"D:\Software\phpstudy_pro\WWW\asks\application\home\view\common\script.html";i:1636163172;s:74:"D:\Software\phpstudy_pro\WWW\asks\application\home\view\common\header.html";i:1636639625;s:74:"D:\Software\phpstudy_pro\WWW\asks\application\home\view\common\footer.html";i:1636163196;}*/ ?>
<!DOCTYPE html>
<html lang="en">

<head>
    <!-- 样式 -->
    <meta charset="utf-8">
<title>基于 layui 的极简社区页面模版</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="keywords" content="fly,layui,前端社区">
<meta name="description" content="Fly社区是模块化前端UI框架Layui的官网社区，致力于为web开发提供强劲动力">
<link rel="stylesheet" href="/static/home/res/layui/css/layui.css">
<link rel="stylesheet" href="/static/home/res/css/global.css">
    <!-- js -->
    <script src="/static/home/res/layui/layui.js"></script>
<script>
    layui.cache.page = '';
    layui.cache.user = {
        username: '游客'
        , uid: -1
        , avatar: '/static/home/res/images/avatar/00.jpg'
        , experience: 83
        , sex: '男'
    };
    layui.config({
        version: "3.0.0"
        , base: '/static/home/res/mods/' //这里实际使用时，建议改成绝对路径
    }).extend({
        fly: 'index'
    }).use('fly');
</script>
</head>

<body>
    <!-- 头部 -->
    <div class="fly-header layui-bg-black">
  <div class="layui-container">
    <a class="fly-logo" href="<?php echo url('home/index/index'); ?>">
      <img src="/static/home/res/images/logo.png" alt="layui">
    </a>

    <ul class="layui-nav fly-nav-user">
      <?php if(!\think\Cookie::get('LoginUser')): ?>
      <!-- 未登入的状态 -->
      <li class="layui-nav-item">
        <a class="iconfont icon-touxiang layui-hide-xs" href="<?php echo url('home/user/index'); ?>"></a>
      </li>
      <li class="layui-nav-item">
        <a href="<?php echo url('home/index/login'); ?>">登入</a>
      </li>
      <li class="layui-nav-item">
        <a href="<?php echo url('home/index/register'); ?>">注册</a>
      </li>
      <?php else: ?>
      <!-- 登入后的状态 -->

      <li class="layui-nav-item">
        <a class="fly-nav-avatar" href="javascript:;">
          <cite class="layui-hide-xs"><?php echo \think\Cookie::get('LoginUser')['nickname']; ?></cite>
          <?php if(\think\Cookie::get('LoginUser')['auth'] == 1): ?>
          <i class="iconfont icon-renzheng layui-hide-xs" title="认证信息:<?php echo \think\Cookie::get('LoginUser')['nickname']; ?>"></i>
          <?php endif; ?>
          <i class="layui-badge fly-badge-vip layui-hide-xs">VIP<?php echo \think\Cookie::get('LoginUser')['vip']; ?></i>
          <img src="<?php echo \think\Cookie::get('LoginUser')['avatar']; ?>">
        </a>
        <dl class="layui-nav-child">
          <dd><a href="<?php echo url('home/user/profile'); ?>"><i class="layui-icon">&#xe620;</i>基本设置</a></dd>
          <dd><a href="<?php echo url('home/user/message'); ?>"><i class="iconfont icon-tongzhi" style="top: 4px;"></i>我的消息</a></dd>
          <dd>
            <a href="<?php echo url('home/user/index'); ?>"><i class="layui-icon"
                style="margin-left: 2px; font-size: 22px;">&#xe68e;</i>我的主页</a>
          </dd>
          <hr style="margin: 5px 0;">
          <dd><a href="<?php echo url('home/index/logout'); ?>" style="text-align: center;">退出</a></dd>
        </dl>
      </li>
      <?php endif; ?>
    </ul>
  </div>
</div>
    <!-- 内容 -->
    <!-- 在线网页编辑器引入 -->
<link rel="stylesheet" href="/static/kindeditor/themes/default/default.css" />
<script src="/static/kindeditor/kindeditor-all-min.js"></script>
<script src="/static/kindeditor/lang/zh-CN.js"></script>
<script>
    var editor;
    KindEditor.ready(function (K) {
        editor = K.create('textarea[name="content"]', {
            allowFileManager: true
        });
    })
</script>


<!-- 二级菜单 -->
<div class="fly-panel fly-column">
    <div class="layui-container">
        <ul class="layui-clear">
            <li class="layui-hide-xs <?php echo $cateid==0?'layui-this' : ''; ?>">
                <a href="<?php echo url('home/index/index'); ?>">全部</a>
            </li>
            <?php foreach($catelist as $item): ?>
            <li class="<?php echo $cateid==$item['id']?'layui-this' : ''; ?>"><a
                    href="<?php echo url('home/index/index',['cateid'=> $item['id']]); ?>"><?php echo $item['name']; ?></a></li>
            <?php endforeach; ?>

            <!-- 用户登入后显示 -->
            <?php if(\think\Cookie::get('LoginUser')): ?>
            <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block">
                <span class="fly-mid"></span>
            </li>
            <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block">
                <a href="javascript:void(0)">我发表的贴</a>
            </li>
            <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block">
                <a href="javascript:void(0)">我收藏的贴</a>
            </li>
            <?php endif; ?>
        </ul>

        <div class="fly-column-right layui-hide-xs">
            <span class="fly-search"><i class="layui-icon"></i></span>
            <a href="<?php echo url('home/post/add'); ?>" class="layui-btn">发表新帖</a>
        </div>

        <div class="layui-hide-sm layui-show-xs-block"
            style="margin-top: -10px; padding-bottom: 10px; text-align: center;">
            <a href="<?php echo url('home/post/add'); ?>" class="layui-btn">发表新帖</a>
        </div>
    </div>
</div>

<!-- 帖子信息 -->
<div class="layui-container">
    <div class="layui-row layui-col-space15">
        <!-- 左侧 -->
        <div class="layui-col-md8 content detail">
            <div class="fly-panel detail-box">
                <!-- 标题 -->
                <h1><?php echo $post['title']; ?></h1>

                <!-- 帖子状态 -->
                <div class="fly-detail-info">
                    <?php if($post['accept']): ?>
                    <span class="layui-badge" style="background-color: #5FB878;">已结</span>
                    <?php else: ?>
                    <span class="layui-badge" style="background-color: #999;">未结</span>
                    <?php endif; if($post['state'] == 1): ?>
                    <span class="layui-badge layui-bg-red">置顶</span>
                    <?php elseif($post['state'] == 2): ?>
                    <span class="layui-badge layui-bg-green">精华</span>
                    <?php elseif($post['state'] == 3): ?>
                    <span class="layui-badge layui-bg-black">热门</span>
                    <?php endif; ?>

                    <span class="fly-list-nums">
                        <!-- 评论数 -->
                        <a href="#comment">
                            <i class="iconfont" title="回答">&#xe60c;</i> <?php echo $count; ?>
                        </a>

                        <!-- 访问次数 -->
                        <i class="iconfont" title="人气">&#xe60b;</i> <?php echo $VisitCount; ?>
                    </span>
                </div>


                <!-- 用户信息 -->
                <div class="detail-about">
                    <!-- 头像链接 -->
                    <a href="<?php echo url('home/user/index', ['userid' => $post['userid']]); ?>" class="fly-avatar">
                        <?php if($post['user']['avatar']): ?>
                        <img src="<?php echo $post['user']['avatar']; ?>" />
                        <?php else: ?>
                        <img src="/static/home/res/images/avatar.jpg" />
                        <?php endif; ?>
                    </a>

                    <div class="fly-detail-user">
                        <!-- 昵称 -->
                        <a href="<?php echo url('home/user/index', ['userid' => $post['userid']]); ?>" class="fly-link">
                            <cite><?php echo $post['user']['nickname']; ?></cite>
                            <?php if($post['user']['auth'] > 0): ?>
                            <i class="iconfont icon-renzheng"></i>
                            <?php endif; ?>
                        </a>

                        <!-- 发布时间 -->
                        <span><?php echo $post['createtime']; ?></span>
                    </div>

                    <!-- 帖子按钮 -->
                    <div class="detail-hits" id="LAY_jieAdmin" data-id="123">
                        <!-- 积分 -->
                        <span style="padding-right: 10px; color: #FF7200">
                            悬赏：<b><?php echo $post['point']; ?></b> 积分
                        </span>

                        <!-- 登录的用户 和 发帖人的id相等 -->
                        <?php if(\think\Cookie::get('LoginUser')['id'] == $post['userid']): ?>
                        <span class="layui-btn layui-btn-xs jie-admin" type="edit">
                            <a href="<?php echo url('home/post/edit', ['postid' => $post['id']]); ?>">编辑此贴</a>
                        </span>

                        <span class="layui-btn layui-btn-xs jie-admin layui-bg-red" type="edit" id="delpost">
                            <a href="javascript:void(0)">删除</a>
                        </span>
                        <?php endif; if(\think\Cookie::get('LoginUser')): if($CollectStatus): ?>
                        <span class="layui-btn layui-btn-xs jie-admin layui-bg-black" type="edit" id="CollectDel">
                            <a href="javascript:void(0)">取消收藏</a>
                        </span>
                        <?php else: ?>
                        <span class="layui-btn layui-btn-xs jie-admin layui-bg-blue" type="edit" id="CollectAdd">
                            <a href="javascript:void(0)">收藏</a>
                        </span>
                        <?php endif; endif; ?>


                    </div>
                </div>

                <!-- 正文内容 -->
                <div class="detail-body photos">
                    <?php echo $post['content']; ?>
                </div>
            </div>


            <div class="fly-panel detail-box" id="flyReply">
                <!-- 回帖的标题 -->
                <fieldset class="layui-elem-field layui-field-title" style="text-align: center;">
                    <legend>回帖</legend>
                </fieldset>

                <ul class="jieda" id="jieda">
                    <?php if($commentlist): ?>
                    <?php echo CommentHtml($commentlist, $post); else: ?>
                    <!-- 无数据时 -->
                    <li class="fly-none">消灭零回复</li>
                    <?php endif; ?>
                </ul>

                <!-- 评论的表单 -->
                <?php if(\think\Cookie::get('LoginUser') AND !$post['accept']): ?>
                <div id="comment" class="layui-form layui-form-pane">
                    <form action="<?php echo url('home/comment/add'); ?>" method="post">
                        <div class="layui-form-item">
                            <h2 id="reply-nickname"></h2>
                        </div>

                        <div class="layui-form-item layui-form-text">
                            <div class="layui-input-block">
                                <textarea id="content" name="content" placeholder="请输入内容" class="layui-textarea"
                                    style="height: 300px;"></textarea>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <input type="hidden" name="pid" value="0" />
                            <input type="hidden" name="postid" value="<?php echo $post['id']; ?>" />
                            <button type="submit" class="layui-btn">提交回复</button>
                        </div>
                    </form>
                </div>
                <?php endif; ?>
            </div>
        </div>

        <!-- 右侧 -->
        <div class="layui-col-md4">
            <dl class="fly-panel fly-list-one">
                <dt class="fly-panel-title">本周热议</dt>
                <dd>
                    <a href="">基于 layui 的极简社区页面模版</a>
                    <span><i class="iconfont icon-pinglun1"></i> 16</span>
                </dd>
                <dd>
                    <a href="">基于 layui 的极简社区页面模版</a>
                    <span><i class="iconfont icon-pinglun1"></i> 16</span>
                </dd>
                <dd>
                    <a href="">基于 layui 的极简社区页面模版</a>
                    <span><i class="iconfont icon-pinglun1"></i> 16</span>
                </dd>
                <dd>
                    <a href="">基于 layui 的极简社区页面模版</a>
                    <span><i class="iconfont icon-pinglun1"></i> 16</span>
                </dd>
                <dd>
                    <a href="">基于 layui 的极简社区页面模版</a>
                    <span><i class="iconfont icon-pinglun1"></i> 16</span>
                </dd>
                <dd>
                    <a href="">基于 layui 的极简社区页面模版</a>
                    <span><i class="iconfont icon-pinglun1"></i> 16</span>
                </dd>
                <dd>
                    <a href="">基于 layui 的极简社区页面模版</a>
                    <span><i class="iconfont icon-pinglun1"></i> 16</span>
                </dd>
                <dd>
                    <a href="">基于 layui 的极简社区页面模版</a>
                    <span><i class="iconfont icon-pinglun1"></i> 16</span>
                </dd>
                <dd>
                    <a href="">基于 layui 的极简社区页面模版</a>
                    <span><i class="iconfont icon-pinglun1"></i> 16</span>
                </dd>
                <dd>
                    <a href="">基于 layui 的极简社区页面模版</a>
                    <span><i class="iconfont icon-pinglun1"></i> 16</span>
                </dd>

                <!-- 无数据时 -->
                <!--
        <div class="fly-none">没有相关数据</div>
        -->
            </dl>

            <!-- 公众号 -->
            <div class="fly-panel" style="padding: 20px 0; text-align: center;">
                <img src="/static/home/res/images/weixin.jpg" style="max-width: 100%;" alt="layui">
                <p style="position: relative; color: #666;">微信扫码关注 layui 公众号</p>
            </div>

        </div>
    </div>
</div>
<script>
    layui.use('layer', function () {
        var layer = layui.layer
        var $ = layui.jquery

        //给删除按钮绑定事件
        $("#delpost").on('click', function () {
            layer.confirm('是否确认删除', { icon: 3, title: '提示' }, function (index) {

                //关闭弹框
                layer.close(index)

                //发送异步请求
                $.ajax({
                    url: `<?php echo url('home/post/del'); ?>`,
                    type: 'post',
                    data: `postid=<?php echo $post['id']; ?>`,
                    dataType: 'json',
                    success: function (success) {
                        if (success.result) {
                            //成功
                            layer.msg(success.msg, {
                                icon: 1,
                                time: 2000 //2秒关闭（如果不配置，默认是3秒）
                            }, function () {
                                location.href = "<?php echo url('home/index/index'); ?>"
                                return false
                            })
                        } else {
                            //删除失败
                            layer.msg(success.msg)
                        }
                    }
                })
            })
        })

        //添加收藏
        $("#CollectAdd").on('click', function () {
            //发送异步请求
            $.ajax({
                url: `<?php echo url('home/collect/add'); ?>`,
                type: 'post',
                data: `postid=<?php echo $post['id']; ?>`,
                dataType: 'json',
                success: function (result) {

                    if (result.code == 1) {
                        // 成功
                        layer.msg(result.msg, {
                            icon: 1,
                            time: 2000 //2秒关闭（如果不配置，默认是3秒）
                        })
                    } else {
                        // 收藏失败
                        layer.msg(result.msg, {
                            icon: 5,
                            time: 2000 //2秒关闭（如果不配置，默认是3秒）
                        })
                    }
                }
            })
        })


        //添加回复
        $(".reply").on('click', function () {
            var pid = $(this).data('pid')
            var nickname = $(this).data('nickname')

            //设置隐藏域
            $(`input[name='pid']`).val(pid)

            $("#reply-nickname").html(`回复给：${nickname}`)

            //让编辑器产生光标
            editor.focus()
        })


        // 采纳
        $(".accept").on('click', function () {

            var $dom = $(this)

            layer.confirm('是否确认采纳答案，积分将打到对应账号', { icon: 3, title: '提示' }, function (index) {

                //评论id
                var comid = $dom.data('comid')

                //关闭弹框
                layer.close(index)

                //发送异步请求
                $.ajax({
                    url: `<?php echo url('home/comment/accept'); ?>`,
                    type: 'post',
                    data: `comid=${comid}`,
                    dataType: 'json',
                    success: function (success) {
                        if (success.result) {
                            //成功
                            layer.msg(success.msg, {
                                icon: 1,
                                time: 2000 //2秒关闭（如果不配置，默认是3秒）
                            }, function () {
                                location.reload()
                            })
                        } else {
                            //失败
                            layer.msg(success.msg)
                        }
                    }
                })
            })
        })


    })
</script>
    <!-- 底部 -->
    <div class="fly-footer">
    <p>2017 &copy; <a href="http://www.layui.com/" target="_blank">Fly技术社区</a></p>
</div>
</body>

</html>